<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

// Make sure no one attempts to run this script "directly"
if (!defined('DBC'))
	exit;

if (file_exists(DBC_ROOT.'templates/'.$DBC_user['style'].'/bbcode/b.png'))
	$btndir = 'templates/'.$DBC_user['style'].'/bbcode/';
else
	$btndir = 'engine/skins/images/bbcode/';
$smldir = 'engine/skins/emoticons/';

require DBC_ROOT.'language/'.$DBC_user['language'].'/bbcode.php';

if (!isset($smilies))
{
	if (file_exists(FORUM_CACHE_DIR.'cache_smilies.php'))
		include FORUM_CACHE_DIR.'cache_smilies.php';
	else
	{
		require_once DBC_ROOT.'engine/cache_smilies.php';
		generate_smiley_cache();
		require FORUM_CACHE_DIR.'cache_smilies.php';
	}
}
$smiley_groups = array();
$smiley_i = array();
$smiley_t = array();
foreach ($smilies as $smiley_text => $smiley_img)
{
	if (isset($smiley_groups[$smiley_img]))
		continue;
	$smiley_groups[$smiley_img] = $smiley_text;
	$smiley_i[] = "'".$smiley_img."'";
	$smiley_t[] = "'".$smiley_text."'";
}

echo '<script type="text/javascript">'."\n";
echo '/* <![CDATA[ */'."\n";
echo 'var bbcode_bar = document.getElementById("bbcode_bar");'."\n";
echo 'if (bbcode_bar) {'."\n";
echo '	var bbcode_sm_vis = true;'."\n";
echo '	var bbcode_cr_vis = true;'."\n";
echo '	var bbcode_sm_img = new Array('.implode(',',$smiley_i).');'."\n";
echo '	var bbcode_sm_txt = new Array('.implode(',',$smiley_t).');'."\n";
echo '	bbcode_bar.innerHTML = "<div id=\"bbcodewrapper\">\\'."\n";
echo '<div id=\"bbcodebuttons\">\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'b.png\" alt=\"[b]\" title=\"'.$lang_bbcode['b'].'\" onclick=\"return insert_text(\'[b]\',\'[/b]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'i.png\" alt=\"[i]\" title=\"'.$lang_bbcode['i'].'\" onclick=\"return insert_text(\'[i]\',\'[/i]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'u.png\" alt=\"[u]\" title=\"'.$lang_bbcode['u'].'\" onclick=\"return insert_text(\'[u]\',\'[/u]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'s.png\" alt=\"[s]\" title=\"'.$lang_bbcode['s'].'\" onclick=\"return insert_text(\'[s]\',\'[/s]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<div class=\"editor_button\"><img src=\"'.$btndir.'spacer.png\" alt=\"|\" /></div>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'c.png\" alt=\"[center]\" title=\"'.$lang_bbcode['center'].'\" onclick=\"return insert_text(\'[center]\',\'[/center]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'r.png\" alt=\"[right]\" title=\"'.$lang_bbcode['right'].'\" onclick=\"return insert_text(\'[right]\',\'[/right]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'justify.png\" alt=\"[justify]\" title=\"'.$lang_bbcode['justify'].'\" onclick=\"return insert_text(\'[justify]\',\'[/justify]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'mono.png\" alt=\"[mono]\" title=\"'.$lang_bbcode['mono'].'\" onclick=\"return insert_text(\'[mono]\',\'[/mono]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<div class=\"editor_button\"><img src=\"'.$btndir.'spacer.png\" alt=\"|\" /></div>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'link.png\" alt=\"[url]\" title=\"'.$lang_bbcode['url'].'\" onclick=\"return insert_text(\'[url]\',\'[/url]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'email.png\" alt=\"[email]\" title=\"'.$lang_bbcode['email'].'\" onclick=\"return insert_text(\'[email]\',\'[/email]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'image.png\" alt=\"[img]\" title=\"'.$lang_bbcode['img'].'\" onclick=\"return insert_text(\'[img]\',\'[/img]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'mp.png\" alt=\"[video]\" title=\"'.$lang_bbcode['video'].'\" onclick=\"return insert_text(\'[video]\',\'[/video]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'mp3.png\" alt=\"[audio]\" title=\"'.$lang_bbcode['audio'].'\" onclick=\"return insert_text(\'[audio]\',\'[/audio]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'youtube.png\" alt=\"[youtube]\" title=\"'.$lang_bbcode['youtube'].'\" onclick=\"return insert_text(\'[youtube]\',\'[/youtube]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<div class=\"editor_button\"><img src=\"'.$btndir.'spacer.png\" alt=\"|\" /></div>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'list.png\" alt=\"[list]\" title=\"'.$lang_bbcode['list'].'\" onclick=\"return insert_text(\'[list]\',\'[/list]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'li.png\" alt=\"[*]\" title=\"'.$lang_bbcode['*'].'\" onclick=\"return insert_text(\'[*]\',\'[/*]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<div class=\"editor_button\"><img src=\"'.$btndir.'spacer.png\" alt=\"|\" /></div>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'quote.png\" alt=\"[quote]\" title=\"'.$lang_bbcode['quote'].'\" onclick=\"return insert_text(\'[quote]\',\'[/quote]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'code.png\" alt=\"[code]\" title=\"'.$lang_bbcode['code'].'\" onclick=\"return insert_text(\'[code]\',\'[/code]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'hide.png\" alt=\"[code]\" title=\"'.$lang_bbcode['hide'].'\" onclick=\"return insert_text(\'[hide]\',\'[/hide]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'hr.png\" alt=\"[hr]\" title=\"'.$lang_bbcode['hr'].'\" onclick=\"return insert_text(\'\',\'[hr]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'title.png\" alt=\"[title]\" title=\"'.$lang_bbcode['title'].'\" onclick=\"return insert_text(\'[title='.$lang_bbcode['title'].']'.$lang_bbcode['description'].'\',\'[/title]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'color.png\" alt=\"[color=]\" title=\"'.$lang_bbcode['color'].'\" onclick=\"return overlay(this, \'bbcode_color_map\', \'rightbottom\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'spoiler.png\" alt=\"[spoiler]\" title=\"'.$lang_bbcode['spoiler'].'\" onclick=\"return insert_text(\'[spoiler]\',\'[/spoiler]\');\" tabindex=\"'.($cur_index++).'\" /></span>\\'."\n";
echo '<div class=\"editor_button\"><img src=\"'.$btndir.'spacer.png\" alt=\"|\" /></div>\\'."\n";
echo '<span class=\"editor_button\"><img src=\"'.$btndir.'emo.png\" alt=\"smile\" title=\"'.$lang_bbcode['smileys'].'\" onclick=\"return overlay(this, \'bbcode_smileys\', \'rightbottom\');\" tabindex=\"'.($cur_index++).'\" onclick=\"ins_emo(this);\" /></span>\\'."\n";
echo '</div>\\'."\n";
echo '</div>\\'."\n";
echo '<div class=\"clearer\"></div>\\'."\n";
echo '<div id=\"bbcode_color_map\" onclick=\"overlayclose(\'bbcode_color_map\');\"></div>\\'."\n";
echo '<div id=\"bbcode_smileys\" onclick=\"overlayclose(\'bbcode_smileys\');\"></div>\\'."\n";
echo '";'."\n";
echo '	bbcode_bar.style.display = "block";'."\n";
echo '	bbcode_bar.style.visibility = "visible";'."\n";
echo '}'."\n";
echo '/* ]]> */'."\n";
echo '</script>'."\n";